//
//  SetLevel2PasswordSuccessController.swift
//  SCA
//
//  Created by tjun on 2025/9/12.
//

import UIKit

class SetLevel2PasswordSuccessController: BaseController {
    
    let text: String
    
    init(text: String) {
        self.text = text
        super.init(nibName: nil, bundle: nil)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let iconBackgroundImageView = UIView()
        iconBackgroundImageView.addTo(self.view)
        iconBackgroundImageView.backgroundColor = UIColorMake(0x2BB673)
        iconBackgroundImageView.addCorner(radius: 48)
        iconBackgroundImageView.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.width.height.equalTo(96)
            make.centerY.equalToSuperview().offset(-120)
        }
        
        let iconImageView = UIImageView(image: UIImage(named: "bigSuccess"))
        iconImageView.addTo(iconBackgroundImageView)
        iconImageView.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
        }
        
        let textLabel = UILabel(text: text, font: UIFontMediumMake(16), textColor: .white).addTo(view)
        textLabel.numberOfLines = 0
        textLabel.attributedText = textLabel.text?.titleMargin(3, font: UIFontMediumMake(16),  alignment: .center)
        textLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(iconBackgroundImageView.snp.bottom).offset(30)
        }
        
        let confirmButton = MainButton(type: .system, title: "OK", font: UIFontMake(16), textColor: .white)
        confirmButton.addTo(self.view)
        confirmButton.addCorner(radius: 10)
        confirmButton.addTarget(self, action: #selector(confirmButtonTapped), for: .touchUpInside)
        confirmButton.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.width.equalTo(246)
            make.height.equalTo(AppStyle.size.smallButtonHeight.scaled)
            make.top.equalTo(textLabel.snp.bottom).offset(46)
        }
    }
    
    @objc func confirmButtonTapped() {
        navigationController?.popViewController(animated: true)
    }
    
 
}
